package com.quasar.hpatient.view.adapter.render;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.ada.adapter.RenderAdapter;
import com.ada.adapter.RenderBuiler;
import com.quasar.hpatient.R;
import com.quasar.hpatient.model.litePalmodel.MedicineTypedb;
import com.quasar.hpatient.model.medicalmodel.PrescriptionDayData;
import com.quasar.hpatient.widget.MyListView;
import com.vise.log.ViseLog;

import org.litepal.crud.DataSupport;

import java.util.List;


/**
 * 历史药单
 * Created by Administrator on 2017/5/24 0024.
 */

public class DrugsTypeRender extends RenderBuiler<PrescriptionDayData.ListBean> implements View.OnClickListener {

    MyListView mlv_list;
    TextView prescription_tv_time;
    TextView tv_record;
    private String stats;

    public String getStats() {
        return stats;
    }

    public void setStats(String stats) {
        this.stats = stats;
    }


    public DrugsTypeRender(Context context) {
        super(context);
    }

    @Override
    public void onClick(View v) {

    }

    RenderAdapter<PrescriptionDayData.ListBean.PerscriptDetailListBean> adapter;

    @Override
    public void render() {

        if (getContent() != null) {
            MedicationListRender builder = new MedicationListRender(getContext());
            builder.setPrescriptionListBean(getContent());
            builder.setStats(getStats());
            adapter = new RenderAdapter<>(getContext(), builder);
            adapter.addAll(getContent().getPerscriptDetailList());
            mlv_list.setAdapter(adapter);
        }

        if(getStats()!=null){
            if(!getStats().equals("AtPrescriptionActivity") || !getStats().equals("HistoryPrescriptionActivity")){
                //当前药单的修改详情
//                Message();
            }
        }
    }

    public void Message(){
        StringBuffer stringBuffer = new StringBuffer();
        if (getContent().getPrescriptionEditHistroyList().size() > 0) {
            for (int i = 0; i < getContent().getPrescriptionEditHistroyList().size(); i++) {
                stringBuffer.append(getContent().getPrescriptionEditHistroyList().get(i).getEidtMessage() + "\n");
            }
        }
        tv_record.setText(stringBuffer.toString());
    }

    @Override
    protected void setUpView(View view) {
        mlv_list = (MyListView) view.findViewById(R.id.mlv_list);
        prescription_tv_time = (TextView) view.findViewById(R.id.prescription_tv_time);
        tv_record = (TextView) view.findViewById(R.id.tv_record);
    }

    @Override
    protected void hookListeners(View view) {

    }

    @Override
    protected int getlayoutid() {
        return R.layout.drugs_type_layout;
    }
}
